import { _decorator, CCInteger, CCString, Component, UITransform, view, Widget } from 'cc';
import { autoComp, rootNode } from '../Basic/Manager/BaseManager';
const { ccclass, property } = _decorator;

@ccclass('TopUIAdapter')
export class TopUIAdapter extends Component {
  @property(Widget)
  private widget: Widget = null;

  @property({
    type: CCInteger,
    visible() {
      return this.widget != null;
    },
  })
  private widget_top: number = 0;

  @property(UITransform)
  private transform: UITransform = null;

  @property({
    type: CCInteger,
    visible() {
      return this.transform != null;
    },
  })
  height: number = 0;

  onLoad() {
    // 获取屏幕高度
    const screenSize = view.getVisibleSize();
    const designSize = view.getDesignResolutionSize();

    if (screenSize.width / screenSize.height > designSize.width / designSize.height) {
      // 宽屏
    } else {
      // 窄屏
      // if (this.widget != null) {
      //   this.widget.top += this.widget_top;
      //   this.widget.updateAlignment();
      //   this.widget.node.children.forEach((child) => {
      //     const widght = child.getComponent(Widget);
      //     if (widght) widght.updateAlignment();
      //   });
      // }
      // if (this.transform != null) {
      //   this.transform.height = this.height;
      // }
    }
  }
}
